package com.imooc.springmvc3.sse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Random;

/**
 * Created by joe on 16-8-12.
 */
@Controller
public class SseController {

    /**
     * 这里使用的输出的媒体类型为text/event-stream,
     * @return
     */
    @RequestMapping(value = "/push",produces = "text/event-stream")
    public String push(){
        Random random = new Random();
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return "data:Testing 1,2,3" + random.nextInt() + "\n\n";
    }
}
